#pragma once

#include "../base/date.h"

OPEN_JLIB_NS


struct MainLoopTimer {

  MainLoopTimer () noexcept : _elapsed(0L), _last(Date::currentMicroseconds()) {
  }

  f64 operator* () noexcept {
    auto now = Date::currentMicroseconds();
    auto dt = now - _last;
    _last = now;
    _elapsed += dt;
    return dt * 0.000001;
  }

  f64 operator~ () const noexcept {
    return _elapsed * 0.000001;
  }

protected:
  s64 _elapsed;
  s64 _last;
};


CLOSE_JLIB_NS